## This code creates Table A3.

# Table A3

data <- colonial_towns_shp # Load the Bago sample

covariates <- c("houses_sd","altitude_sd","slope_idx_sd","soil_quality_sd","yangon_dist_sd","river_dist_sd") # List of covariates for balance check

balance_check <- matrix(nrow = 7,ncol=7) # Create empty data frame for balance check

# Loop regressions with headman status as DV and covariate as IV

for(i in 1:length(covariates)){
  balance_check[1,i+1] <- covariates[i]
  model <-  conleyreg(paste0("replaced~",covariates[i],"+as.factor(year)+as.factor(district)+longitude_2+latitude_2"),data=data@data,dist_cutoff=100,lat="latitude",lon="longitude",gof=TRUE)
  coef <- round(model$coefficients[2],digits=4)
  se <- round(model$coefficients[2,2],digits=4)
  balance_check[2,i+1] <- coef
  balance_check[3,i+1] <- paste0("(",se,")")
  balance_check[4,i+1] <- paste0("[",round(coef-1.96*se,digits=4),",")
  balance_check[5,i+1] <- paste0(round(coef+1.96*se,digits=4),"]")
  balance_check[6,i+1] <- nobs(model)
  balance_check[7,i+1] <- round(model$adj.r.squared,digits=4)
}

# Produce table

xtable(balance_check)

